<?php

namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class ContactsysController extends AdminbaseController {
    public function index() {
    	$p=1;
    	if (isset($_GET['p'])){
    		$p=$_GET['p'];
    	}
    	$Model = M();
    	$query=$Model->query("SELECT count(id) as count FROM `liuyan`  ");
    	$count=$query[0]['count'];
    	$page = $this->page($count, 10, $p);
    	$queryData=$Model->query("SELECT * FROM `liuyan`  limit ".(($p-1)*10).",10 ");
  
    	$this->assign("page", $page->show('Admin'));
    	$this->assign("queryData", $queryData);
        $this->display();
    }
  
    public function delete() {
    	if (isset($_GET['id'])){
    		$id=$_GET['id'];
    		$Model = M();
    		$deleter = M("yan", 'liu');
    		$deleter->where('id='.$id)->delete();
    		$info=json_encode(array('state'=>'success','info'=>'删除成功','referer'=>'admin.php?g=Admin&m=Contactsys&a=index'));
    		echo $info;
    	}
    }
    
    public function edit() {
    	if (isset($_GET['id'])){
    		$id=$_GET['id'];
    	}else{
    		exit;
    	}
    	$Model = M();
    	$getInfo=$Model->query("SELECT * FROM `liuyan` where id='".$id."' limit 0,1 ");
    	$this->assign("getInfo", $getInfo[0]);
    	$this->display();
    }
     
    
}
